package com.audaque.springboot.foshanupload.web.raspcloud.controller.ext;

import com.audaque.springboot.foshanupload.authcore.controller.AbstractAuthenticationController;
import com.audaque.springboot.foshanupload.core.util.encode.SpringBase64Utils;
import com.audaque.springboot.foshanupload.web.raspcloud.req.ext.RegisterReq;
import com.audaque.springboot.foshanupload.web.raspcloud.service.IUserService;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * @author zgb
 * @desc ...
 * @date 2022-06-28 21:53:02
 */

@Slf4j
@RequestMapping("authentication")
@RestController
public class AuthenticationController extends AbstractAuthenticationController {

    @Autowired
    private IUserService userService;



    @GetMapping(value = "encode")
    @ApiOperation(value = "加密")
    public String encode(String text) {
        //前端密码加密：Aa12345678
        //cookie加密
        return SpringBase64Utils.encode(text);
    }
    @GetMapping(value = "decode")
    @ApiOperation(value = "解密")
    public String decode(String text) {
        //b95495d2b655e0cd832244427261b76a
        return SpringBase64Utils.decode(text);
    }
    @PostMapping("/register")
    public void register(@RequestBody @Valid RegisterReq registerReq) throws Exception {
        userService.register(registerReq);
    }






}
